package com.fhz.a2102mvi.module

import android.content.Context
import androidx.room.Room
import com.fhz.a2102mvi.dao.BannerDao
import com.fhz.a2102mvi.database.MyDatabase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
 * 时间:2023/10/19
 * @author Mr.Feng
 * 简述: TODO
 */
@Module
@InstallIn(SingletonComponent::class)
class DatabaseModule {

    @Provides
    @Singleton
    fun providesDatabase(@ApplicationContext context: Context) : MyDatabase{
        return Room.databaseBuilder(
            context,
            MyDatabase::class.java, "a2102mvi"
        ).build()
    }

    @Provides
    @Singleton
    fun providesBannerDao(myDatabase: MyDatabase) : BannerDao {
        return myDatabase.bannerDao()
    }


}